Empresas
Empleos
  • Sobre nosotros
  • Soluciones
    • Publicación de vacantes
      Publica tu vacante y recibe candidatos calificados en 48h.
    • Evaluación de candidatos
      500+ pruebas técnicas y psicológicas, más anti-fraude.
    • Headhunting
      Búsqueda ejecutiva a la medida de principio a fin.
    • Nómina + EOR
      Dispersión de nómina y EOR en más de 15 países de LATAM.
  • Precios
  • Empleos

0

890
Vistas
"Runtime.UserCodeSyntaxError" while trying to declare an async AWS Lambda function

I've had an old AWS Lambda function, that was declared as synchronous (used Promises), the declaration looked like this:

exports.getSong = (event, context, callback) => { }

It worked as intended. Recently, I decided to re-write it using async/await and thus, tried declaring the getSong function asynchronously, like so:

exports.getSong = async (event, context) => { }

And while trying to execute, I get the following error in it's entirety:

{
  "errorType": "Runtime.UserCodeSyntaxError",
  "errorMessage": "SyntaxError: Unexpected token '.'",
  "trace": [
    "Runtime.UserCodeSyntaxError: SyntaxError: Unexpected token '.'",
    "    at _loadUserApp (/var/runtime/UserFunction.js:98:13)",
    "    at Object.module.exports.load (/var/runtime/UserFunction.js:140:17)",
    "    at Object.<anonymous> (/var/runtime/index.js:43:30)",
    "    at Module._compile (internal/modules/cjs/loader.js:1133:30)",
    "    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1153:10)",
    "    at Module.load (internal/modules/cjs/loader.js:977:32)",
    "    at Function.Module._load (internal/modules/cjs/loader.js:877:14)",
    "    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:74:12)",
    "    at internal/main/run_main_module.js:18:47"
  ]
}

It absolutely not clear what the issue is from this error message, but by googling for similar issues and narrowing everything down, I figured out that the problem is the function declaration.

I tried declaring the getSong function as synchronous, and then running another asynchronous function inside it, like so:

var anotherAsyncFunction = async () => { }
exports.getSong = (event, context, callback) => { anotherAsyncFunction() }
    

But then, I get the same error. So clearly, it has something to do with the Asynchronous function declaration inside the Lambda. What might be the issue here? Thank you.

over 4 years ago · Santiago Trujillo
1 Respuestas
Responde la pregunta

0

I encounter a similar issue. for me it was res.Body?.toString('utf-8') which lambda could not understand what is Body?. i think in your case you should do the following :

export const getSong = async (event, context) => { ...}

also for whoever has the same problem, the best way to figure out the reason is to go to your lambda code page, it should show a red X on the line of code

over 4 years ago · Santiago Trujillo Denunciar
Responde la pregunta
Encuentra empleos remotos

¡Descubre la nueva forma de encontrar empleo!

Top de empleos
Top categorías de empleo
Empresas
Publicar vacante Precios Comercial
Legal
Términos y condiciones Política de privacidad
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomiéndame algunas ofertas
Necesito ayuda